/* 
 * File:   StreamOperationFactroy.cpp
 * Author: hao
 * 
 * Created on 2011年4月14日, 下午8:36
 */

#include "StreamOperationFactroy.h"

StreamOperationFactroy::StreamOperationFactroy() {
}

int StreamOperationFactroy::addOperationPlugin(const char* path){

    StreamOperationCore * pCore = new StreamOperationCore( path );

    if( !pCore->init() ){
        delete pCore;
        return -1;
    }
    
    OperationVector.push_back( pCore );
    return OperationVector.size() - 1;
}

void StreamOperationFactroy::Destroy(){

    for( unsigned i = 0; i < OperationVector.size(); i++ ){
        delete OperationVector[i];
    }

    OperationVector.clear();

}

StreamOperationPlugin * StreamOperationFactroy::getOperationPlugin(unsigned index){
    if( index >= OperationVector.size() ) return NULL;

    return OperationVector[ index ];

}

StreamOperationFactroy::~StreamOperationFactroy() {

    Destroy();

}

